/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package datos;

import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Magaly
 */
public class Conexion {
    Connection con;
    public Conexion() {
        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String db="jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb, *.accdb);DBQ=C:/BD/Papeleria.accdb";
            con=DriverManager.getConnection(db,"","");
            con.setAutoCommit(false);
        }
        catch (SQLException ex)
        {
            Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
        }
        catch (ClassNotFoundException ex) 
        {
            Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public Connection getConeccion() 
    {
        return con;
    }
    
    public void Desconectar()
    {
        try 
        {
            con.close();
        } catch (SQLException ex)
        {
            Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public void Commit()
    {
        try
        {
            con.commit();
        } catch (SQLException ex) {
            Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public void RollBack(){
        try 
        {
            con.rollback();
        }
        catch (SQLException ex) 
        {
            Logger.getLogger(Conexion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}
